package com.hzcx.app.simplechat.ui.setting.presenter;

import android.content.Context;

import com.hzcx.app.simplechat.api.BaseDialogObserver;
import com.hzcx.app.simplechat.base.BaseEmptyBean;
import com.hzcx.app.simplechat.base.BasePresenter;
import com.hzcx.app.simplechat.model.LoginModel;
import com.hzcx.app.simplechat.model.PublicModel;
import com.hzcx.app.simplechat.ui.publicui.bean.ProtocolBean;
import com.hzcx.app.simplechat.ui.setting.contract.AboutContract;
import com.hzcx.app.simplechat.ui.setting.contract.UpdatePwdContract;
import com.hzcx.app.simplechat.util.UserInfoUtil;
import com.hzcx.app.simplechat.util.empty.EmptyUtils;

public class UpdatePwdPresenter extends BasePresenter<UpdatePwdContract.View> implements UpdatePwdContract.Presenter {

    /**
     * 发送验证码
     *
     * @param context
     * @param mobile
     * @param event
     * @param area_code
     */
    @Override
    public void sendCode(Context context, String mobile, String event, String area_code) {
        PublicModel.sendCode(context, mobile, event, UserInfoUtil.getUserPhoneCityCode(), new BaseDialogObserver<BaseEmptyBean>(context) {
            @Override
            protected void onSuccess(BaseEmptyBean data) {
                mView.sendSuccess();
            }
        });
    }

    /**
     * 修改密码
     *
     * @param context
     * @param newpassword
     * @param captcha
     * @param mobile
     */
    @Override
    public void updatePwd(Context context, String newpassword, String captcha, String mobile) {
        LoginModel.forgetPwd(context, newpassword, captcha, mobile, new BaseDialogObserver<BaseEmptyBean>(context) {
            @Override
            protected void onSuccess(BaseEmptyBean data) {
                mView.updateSuccess();
            }
        });
    }

    /**
     *  获取协议内容
     * @param context
     * @param type
     */
    @Override
    public void getProtocol(Context context, String type) {
        PublicModel.getProtocolByType(context, type, new BaseDialogObserver<ProtocolBean>(context) {
            @Override
            protected void onSuccess(ProtocolBean data) {
                mView.protocolResult(data);
            }
        });
    }
}
